*GENERAL INFO
	* Project: How to Close the Gender Gap in Political Participation: Lessons from Matrilineal Societies in Africa
	* Authors: Amanda Robinson and Jessica Gottlieb
	* Date created: Dec. 2018
* DO FILE INFO
	* This .do file performs all reported analyses of the Malawi quantitative data.
    * This file calls RG_Matlin_Mal_clean.do to prepare the data before running analyses.

* SET WORKING DIRECTORY
	* Set the working directory to the folder in which all replication files are stored.
    * Make sure that the MLFSH datasets listed above into a folder within the working directory called "MLFSH_Data".
		
****************************************************************
qui: do RG_Matlin_Mal_clean.do
* Produce a log file
*log using RG_Matlin_Mal_log, replace

***********************************
* Effect of Land Inheritance
***********************************
set more off

*DV=chiefmeeting

reg chiefmeeting i.female##i.kinland , vce(cluster DK_village_number)
est sto chief
margins, predict() by(kinland female)
marginsplot, name(chief_pp, replace) ytitle (`: variable label chiefmeeting') scheme(plotplainblind) ///
    title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore chief
margins, dydx(female) by(kinland)
marginsplot, name(chief, replace) ytitle ("Marginal Effect of Gender (Female) on""`: variable label chiefmeeting'", color(black) size(msmall)) scheme(plotplainblind) ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 
	 
ivreg2 chiefmeeting  (i.kinland##i.female = i.matlin##i.female2), cluster( DK_village_number)  partial(_cons)
est sto iv_chief_first  
ivregress 2sls chiefmeeting  (i.kinland##i.female = i.matlin##i.female2), vce(cluster DK_village_number)  
est sto iv_chief
    * Note: female=female, created to allow for factor variables
            * produces exact same results if manually create interactions b/w female and matlin/kinland
            * but this coding allows the use of margins/marginsplot
margins, predict() by(kinland female)
marginsplot, name(iv_chief_pp, replace) ytitle ("") scheme(plotplainblind) ///
	 xtitle("Inherited Matrilineal Land" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore iv_chief
margins, dydx(female) by(kinland)
marginsplot, name(iv_chief, replace) ytitle ("") scheme(plotplainblind) ///
	xtitle("Inherited Matrilineal Land" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 

** DV=justleave

set more off
reg justleave i.female##i.kinland , vce(cluster DK_village_number)
est sto justleave
margins, predict() by(kinland female)
marginsplot, name(justleave_pp, replace) ytitle (`: variable label justleave') scheme(plotplainblind) ///
    title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore justleave
margins, dydx(female) by(kinland)
marginsplot, name(justleave, replace) ytitle ("Marginal Effect of Gender (Female) on""`: variable label justleave'", color(black) size(msmall)) scheme(plotplainblind) ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 
	 
ivreg2 justleave  (i.kinland##i.female = i.matlin##i.female2), cluster( DK_village_number)  partial(_cons)
est sto iv_justleave_first  
ivregress 2sls justleave  (i.kinland##i.female = i.matlin##i.female2), vce(cluster DK_village_number)  
est sto iv_justleave
    * Note: female=female, created to allow for factor variables
            * produces exact same results if manually create interactions b/w female and matlin/kinland
            * but this coding allows the use of margins/marginsplot
margins, predict() by(kinland female)
marginsplot, name(iv_justleave_pp, replace) ytitle (`: variable label justleave') scheme(plotplainblind) ///
	 xtitle("Inherited Matrilineal Land" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore iv_justleave
margins, dydx(female) by(kinland)
marginsplot, name(iv_justleave, replace) ytitle ("") scheme(plotplainblind) ///
	xtitle("Inherited Matrilineal Land" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 



***********************************
* Effect of Matrilocal Residence
***********************************
set more off

* DV=chiefmeeting
reg chiefmeeting i.female##i.matrilocal , vce(cluster DK_village_number)
est sto chief_matloc
margins, predict() by(matrilocal female)
marginsplot, name(chief_matloc_pp, replace) ytitle (`: variable label chiefmeeting') scheme(plotplainblind) ///
    title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore chief_matloc
margins, dydx(female) by(matrilocal)
marginsplot, name(chief_matloc, replace) ytitle ("Marginal Effect of Gender (Female) on""`: variable label chiefmeeting'", color(black) size(msmall)) scheme(plotplainblind) ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 
	 
ivreg2 chiefmeeting  (i.matrilocal##i.female = i.matlin##i.female2), cluster( DK_village_number)  partial(_cons)
est sto iv_chief_matloc_first  
ivregress 2sls chiefmeeting  (i.matrilocal##i.female = i.matlin##i.female2), vce(cluster DK_village_number)  
est sto iv_chief_matloc
    * Note: female=female, created to allow for factor variables
            * produces exact same results if manually create interactions b/w female and matlin/matrilocal
            * but this coding allows the use of margins/marginsplot
margins, predict() by(matrilocal female)
marginsplot, name(iv_chief_matloc_pp, replace) ytitle ("") scheme(plotplainblind) ///
	 xtitle("Matrilocal Residence" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore iv_chief_matloc
margins, dydx(female) by(matrilocal)
marginsplot, name(iv_chief_matloc, replace) ytitle ("") scheme(plotplainblind) ///
	xtitle("Matrilocal Residence" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 


* DV=justleave
reg justleave i.female##i.matrilocal , vce(cluster DK_village_number)
est sto justleave_matloc
margins, predict() by(matrilocal female)
marginsplot, name(justleave_matloc_pp, replace) ytitle ("") scheme(plotplainblind) ///
    title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore justleave_matloc
margins, dydx(female) by(matrilocal)
marginsplot, name(justleave_matloc, replace) ytitle ("Marginal Effect of Gender (Female) on""`: variable label justleave'", color(black) size(msmall)) scheme(plotplainblind) ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 
	 
ivreg2 justleave  (i.matrilocal##i.female = i.matlin##i.female2), cluster( DK_village_number)  partial(_cons)
est sto iv_justleave_matloc_first  
ivregress 2sls justleave  (i.matrilocal##i.female = i.matlin##i.female2), vce(cluster DK_village_number)  
est sto iv_justleave_matloc
    * Note: female=female, created to allow for factor variables
            * produces exact same results if manually create interactions b/w female and matlin/matrilocal
            * but this coding allows the use of margins/marginsplot
margins, predict() by(matrilocal female)
marginsplot, name(iv_justleave_matloc_pp, replace) ytitle ("") scheme(plotplainblind) ///
	 xtitle("Matrilocal Residence" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white))  
est restore iv_justleave_matloc
margins, dydx(female) by(matrilocal)
marginsplot, name(iv_justleave_matloc, replace) ytitle (`: variable label justleave') scheme(plotplainblind) ///
	xtitle("Matrilocal Residence" "(Instrumented by Ethnic Group Kinship Practices)") ///
     title("") legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid) ///
	 plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 
	
	
	
*** Create Figures  ***

* Figure 3a
graph combine chief iv_chief, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/chief_matlin.pdf", replace

* Figure A.10
graph combine chief_pp iv_chief_pp, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/chief_matlin_pp.pdf", replace

* Figure 3b
graph combine chief_matloc iv_chief_matloc, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/chief_matloc.pdf", replace

* Figure A.11
graph combine chief_matloc_pp iv_chief_matloc_pp, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/chief_matloc_pp.pdf", replace

* Figure 4
graph combine iv_justleave_pp iv_justleave_matloc_pp, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon  cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/iv_justleave.pdf", replace

* Figure A.12
graph combine justleave_pp justleave_matloc_pp , graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/justleave_noniv.pdf", replace




***********************************
* Effect of Non-Inherited Land (H1)
***********************************

* DV=chiefmeeting
eststo nonkinland_chief: reg chiefmeeting kinland nonkinland  if female==1, vce(cluster DK_village_number)
coefplot, drop(_cons ) xline(0) scheme(plotplainblind) ///
	headings(kinland = "{bf:No Land Ownership to}") ///
	coeflabel(kinland = "Inherited Matrilineal Land" nonkinland = "Owns Non-Matrilineal Land", notick labgap(5)) ///
    xtitle("Change in Attending a Meeting w/ Chief", size(small)) ///
    byopts(row(1)) name(nonkinland_chief, replace) 
* DV=justleave
eststo nonkinland_justleave: reg justleave kinland nonkinland  if female==1, vce(cluster DK_village_number)
coefplot, drop(_cons ) xline(0) scheme(plotplainblind) ///
	headings(kinland = "{bf:No Land Ownership to}") ///
	coeflabel(kinland = "Inherited Matrilineal Land" nonkinland = "Owns Non-Matrilineal Land", notick labgap(5)) ///
    xtitle("Change in Progressive Gender Norms", size(small)) ///
	xscale(r(-0.5 1.5)) xlabel(#5) ///
    byopts(row(1)) name(nonkinland_justleave, replace)

* Figure 5
graph combine nonkinland_chief nonkinland_justleave, graphregion(fcolor(white) ilcolor(white) lcolor(white)) cols(2) ///
    title("") name(graph, replace)
graph display graph, xsize(10) ysize(6) 
*graph export "Figures/nonkinland.pdf", replace


***********************************
* Effect of Matlin on Education Gap (H2)
***********************************
** DV=education (education gap by gendeer of children within household)
set more off
    * Land Inheritance
reg edgap i.kinland  if female==1, vce(cluster DK_village_number)
est sto edgap
margins, predict() by(kinland)
marginsplot, name(edgap, replace) ytitle (`: variable label edgap') scheme(plotplainblind) ///
		xtitle("Matrilineal Land Inheritance") title("") ///
     legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid)  ///
	 	plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 	
 	 
ivregress 2sls edgap  (i.kinland = i.matlin) if female==1, vce(cluster DK_village_number)
est sto iv_edgap
margins, predict() by(kinland)
marginsplot, name(iv_edgap, replace) ytitle (`: variable label edgap') title("")  scheme(plotplainblind) ///
	 xtitle("Matrilineal Land Inheritance" "(Instrumented by Ethnic Group Kinship Practices)") ///
     legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid)  ///
	 	plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 

    * Matrilocal Residence
reg edgap i.matrilocal  if female==1, vce(cluster DK_village_number)
est sto edgap_matloc
margins, predict() by(matrilocal)
marginsplot, name(edgap_matloc, replace) ytitle ("") title("")  scheme(plotplainblind) ///
		xtitle("Matrilocal Residence") ///
     legend(pos(6) ring(0)) xscale(range(-0.25 1.25))  xlabel(, nogrid) ///
	 	plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 	
	 
ivregress 2sls edgap  (i.matrilocal = i.matloc) if female==1, vce(cluster DK_village_number)
est sto iv_edgap_matloc
margins, predict() by(matrilocal)
marginsplot, name(iv_edgap_matloc, replace) ytitle ("") title("")  scheme(plotplainblind) ///
	xtitle("Matrilocal Residence" "(Instrumented by Ethnic Group Kinship Practices)") ///
     legend(pos(6) ring(0)) xscale(range(-0.25 1.25)) xlabel(, nogrid)  ///
	 	plotopts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 	

* Figure 6
graph combine  iv_edgap iv_edgap_matloc, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/edgap.pdf", replace

*Figure A.13
graph combine edgap edgap_matloc , graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/edgap_noniv.pdf", replace



***********************************
* Norms/Coordination (H3)
***********************************

** Matrilineal Land Inheritance **
set more off

* DV = chiefmeeting
set more off
reg chiefmeeting c.pmatvillage##i.female##i.kinlandfem , vce(cluster DK_village_number)
est sto vill_chief

* DV = justleave
set more off
reg justleave c.pmatvillage##i.female##i.kinlandfem , vce(cluster DK_village_number)
est sto vill_justleave
margins, predict() by(female kinlandfem) at(pmatvillage=(0(0.1).8)) 
marginsplot, name(village_justleave, replace) ytitle (`: variable label justleave') scheme(plotplainblind) ///
	 title("") /// 
	 	xlabel(, nogrid)  ///
    legend(pos(5) ring(0) order(1 "Male" 2 "Female, Patrilocal" 3 "Female, Matrilocal")) ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	plot3opts(msymbol(D) mcolor(ltblue) lcolor(ltblue) ) ci3opts(lcolor(ltblue) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 

* DV = divorce
set more off
reg divorce c.pmatvillage##i.kinland  if female==1, vce(cluster DK_village_number)
est sto vill_divorce
margins, predict() by(kinland) at(pmatvillage=(0(0.1).8)) 
marginsplot, name(village_divorce, replace) ytitle (`: variable label divorce') scheme(plotplainblind) ///
	 title("") ///
    legend(pos(5) ring(0) order(1 "No Inherited Land" 2 "Inherited Land")) ///
	xlabel(, nogrid)  ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 	
 	 

** Matrilocality **

* DV = chiefmeeting
set more off
reg chiefmeeting c.plocvillage##i.female##i.localfem , vce(cluster DK_village_number)
est sto vill_chief_loc

* DV = justleave
set more off
reg justleave c.plocvillage##i.female##i.localfem , vce(cluster DK_village_number)
est sto vill_justleave_loc
margins, predict() by(female localfem) at(plocvillage=(0(0.1).8)) 
marginsplot, name(village_justleave_loc, replace) ytitle (`: variable label justleave') scheme(plotplainblind) ///
	 title("") /// 
	 	xlabel(, nogrid)  ///
    legend(pos(5) ring(0) order(1 "Male" 2 "Female, Patrilocal" 3 "Female, Matrilocal")) ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	plot3opts(msymbol(D) mcolor(ltblue) lcolor(ltblue) ) ci3opts(lcolor(ltblue) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 

* DV = divorce
set more off
reg divorce c.plocvillage##i.matrilocal  if female==1, vce(cluster DK_village_number)
est sto vill_divorce_loc
margins, predict() by(matrilocal) at(plocvillage=(0(0.1).8)) 
marginsplot, name(village_divorce_loc, replace) ytitle (`: variable label divorce') scheme(plotplainblind) ///
	 title("") ///
    legend(pos(5) ring(0) order(1 "No Inherited Land" 2 "Inherited Land")) ///
	xlabel(, nogrid)  ///
	plot1opts(msymbol(O) mcolor(black) lcolor(black) ) ci1opts(lcolor(black) msiz(0))   ///
	plot2opts(msymbol(S) mcolor(gs10) lcolor(gs10) ) ci2opts(lcolor(gs10) msiz(0))   ///
	graphregion(fcolor(white) ilcolor(white) lcolor(white)) 	

* Figure 8
graph combine  village_justleave village_justleave_loc, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon  cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/noniv_village_justleave.pdf", replace

* Figure A.14
graph combine  village_divorce village_divorce_loc, graphregion(fcolor(white) ilcolor(white) lcolor(white)) xcommon ycommon  cols(2) name(graph, replace)
graph display graph, xsize(10) ysize(5)
*graph export "Figures/village_divorce.pdf", replace


**Graphs comparing social effect of matrilineality to individual effect (and associated tables)

* Figure 7
interflex chiefmeeting female pmatvillage if kinlandfem==0, cluster(DK_village_number) ///
	xlabel(Proportion of Women in Village with Matrilineally Inherited Land) dlabel(Patrilineal Female (relative to All Males)) 
graph rename land_female, replace
*graph export "Figures/village_chief_kinland.pdf", replace
interflex chiefmeeting kinland pmatvillage if female==1, cluster( DK_village_number) xlabel(Proportion of Women in Village with Matrilineally Inherited Land) dlabel(Matrilineal Land (among Women Only)) title(Direct Effect on Attendance at Chief Meeting) 
graph rename land_kinland, replace
interflex chiefmeeting female plocvillage if localfem==0, cluster(DK_village_number) xlabel(Proportion of Women in Village with Matrilocal Residence) dlabel(Patrilocal Female (relative to All Males)) 
graph rename loc_female, replace
*graph export "Figures/village_chief_matriloc.pdf", replace
interflex chiefmeeting matrilocal plocvillage if female==1, cluster( DK_village_number) xlabel(Proportion of Women in Village with Matrilocal Residence) dlabel(Matrilocal Residence (among Women Only))  
graph rename loc_kinland, replace


set more off
reg chiefmeeting c.pmatvillage##i.female  if kinlandfem==0, vce(cluster DK_village_number)
est sto land_female
reg chiefmeeting c.pmatvillage##i.kinland  if female==1, vce(cluster DK_village_number)
est sto land_kinland
reg chiefmeeting c.plocvillage##i.female  if localfem==0, vce(cluster DK_village_number)
est sto loc_female
reg chiefmeeting c.plocvillage##i.matrilocal  if female==1, vce(cluster DK_village_number)
est sto loc_kinland


*****************************
***        Tables       ****
*****************************

* Add F-stats to 2SLS models
global ivest iv_chief iv_chief_matloc iv_justleave iv_justleave_matloc  
foreach e in $ivest {
est restore `e'_first
tempname f
scalar `f'= e(cdf)
est restore `e'
estadd scalar fs `f' 
}


* Matrilocal Practices and Chief Meetings
* Table A.10
esttab chief iv_chief  chief_matloc iv_chief_matloc  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N fs,layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels("Individuals" `"\(F\)"') f(0 2)) ///
	title(Matrilineal Practices and Attending a Meeting with the Chief\label{tab:chief})  ///
	varlabels (1.female Female 1.female#1.kinland "Female $\times$ Matrilineal Land" 1.kinland "Matrilineal Land" ///
    1.matrilocal "Matrilocal Residence" 1.female#1.matrilocal "Female $\times$ Matrilocal Residence" _cons Constant) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.7}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear and 2SLS regressions with standard errors clustered by village." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

* Matrilocal Practices and Gender Norms
* Table A.11
esttab justleave iv_justleave  justleave_matloc iv_justleave_matloc  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N fs,layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels("Individuals" `"\(F\)"') f(0 2)) ///
	title(Matrilineal Practices and Progressive Gender Norms\label{tab:just})  ///
	varlabels (1.female Female 1.female#1.kinland "Female $\times$ Matrilineal Land" 1.kinland "Matrilineal Land" ///
    1.matrilocal "Matrilocal Residence" 1.female#1.matrilocal "Female $\times$ Matrilocal Residence" _cons Constant) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.7}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear and 2SLS regressions with standard errors clustered by village." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

* Non-Kinland vs. Kinland
* Talbe A.12
esttab nonkinland_chief nonkinland_justleave  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N,layout("\multicolumn{1}{c}{@}") labels("Individuals") f(0)) ///
	title(Sources of Land Ownership, Political Participation, and Progressive Gender Norms Among Women\label{tab:nonkinland})  ///
	varlabels (kinland "Owns Matrilineal Land" _cons Constant) ///
	nonotes  nobaselevels  nogaps  ///
    sub("\begin{tabular}" "\scalebox{0.7}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear regressions with standard errors clustered by village.""Women respondents only." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

* Education Gap
* Table A.13
esttab edgap iv_edgap  edgap_matloc iv_edgap_matloc  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N fs,layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") labels("Individuals" `"\(F\)"') f(0 2)) ///
	title(Matrilineal Practices and the Gender Gap in Children's Education within Households\label{tab:edgap})  ///
	varlabels (1.female Female 1.female#1.kinland "Female $\times$ Matrilineal Land" 1.kinland "Matrilineal Land" ///
    1.matrilocal "Matrilocal Residence" 1.female#1.matrilocal "Female $\times$ Matrilocal Residence" _cons Constant) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.7}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Dependent variable is average education of daughters - average education of sons." ///
    "Linear and 2SLS regressions with standard errors clustered by village.""Women respondents with at least one son and one daughter only." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

* Concentration of Matrilocal Practices and Chief Meetings
* Table A.14
esttab vill_chief  vill_chief_loc  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N,layout("\multicolumn{1}{c}{@}") labels("Individuals") f(0 2)) ///
	title(Concentration of Matrilineal Practices and Attending a Meeting with the Chief\label{tab:village_chief})  ///
	varlabels (1.female Female  _cons Constant) ///
    order (1.female pmatvillage 1.female#c.pmatvillage) ///
	drop (1.female#1.kinlandfem 1.female#1.kinlandfem#c.pmatvillage 1.female#1.localfem 1.female#1.localfem#c.plocvillage) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.8}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear regressions with standard errors clustered by village." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

* Comparing Indirect to Direct Effects of Matrilineal Practice on Political Participation
* Table A.15
esttab land_female loc_female  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N,layout("\multicolumn{1}{c}{@}") labels("Individuals") f(0 2)) ///
	title(Indirect Effect of Matrilineal Practice on Political Participation\label{tab:indirect})  ///
	varlabels (1.female Female 1.matrilocal Matrilocal 1.kinland "Matrilineal Land" 1.kinland#c.pmatvillage "Matrilineal Land $\times$ Prop of Women in Village with Matrilineally Inherited Land" 1.matrilocal#c.plocvillage "Matrilocal $\times$ Prop of Women in Village with Matrilocal Residence"  _cons Constant) ///
    order (1.female pmatvillage 1.female#c.pmatvillage) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.8}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear regressions with standard errors clustered by village." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")


* Concentration of Matrilocal Practices and Gender Norms
* Table A.16
esttab vill_justleave  vill_justleave_loc  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N,layout("\multicolumn{1}{c}{@}") labels("Individuals") f(0 2)) ///
	title(Matrilineal Practices and Progressive Gender Norms\label{tab:village_justleave})  ///
	varlabels (1.female Female  _cons Constant) ///
    order (1.female pmatvillage 1.female#c.pmatvillage) ///
	drop (1.female#1.kinlandfem 1.female#1.kinlandfem#c.pmatvillage 1.female#1.localfem 1.female#1.localfem#c.plocvillage) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.8}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear regressions with standard errors clustered by village." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")

* Concentration of Matrilocal Practices and Divorce
* Table A.17
esttab vill_divorce  vill_divorce_loc  /// 
	, star(* 0.10 ** 0.05 *** 0.01) se b(3) se(3) r2(2) label  booktabs alignment(D{.}{.}{-1}) replace ///
    stats(N,layout("\multicolumn{1}{c}{@}") labels("Individuals") f(0 2)) ///
	title(Matrilineal Practices and Divorce\label{tab:village_divorce})  ///
	varlabels (1.matrilocal Matrilocal 1.kinland "Matrilineal Land" 1.kinland#c.pmatvillage "Matrilineal Land $\times$ Prop of Women in Village with Matrilineally Inherited Land" 1.matrilocal#c.plocvillage "Matrilocal $\times$ Prop of Women in Village with Matrilocal Residence"  _cons Constant) ///
	nonotes  nobaselevels  nogaps nomtitles ///
    sub("\begin{tabular}" "\scalebox{0.8}{\begin{tabular}" "\end{tabular}" "\end{tabular}}") ///
	addnote("Linear regressions with standard errors clustered by village." "$^* p<0.10$, $^{**} p<0.05$, $^{***} p<0.01$")



* Close log and convert log file
*log close
*translate RG_Matlin_Mal_log.smcl RG_Matlin_Mal_log.pdf, replace


